package com.itheima.mapper;

import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Mapper//加注解哦
public interface EmpMapper {



   // 这里对应的sql 在xml上
   void delete(ArrayList<Integer> ids);
   // 这是 完成条件查询 动态sql 写到xml
   List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);


    @Insert("insert into emp (username,name,gender,image,job,entrydate,dept_id,create_time,update_time)" +
            " values(#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);

    // 根据id查询 一个员工信息
    @Select("select * from emp where id=#{id}")
    Emp findById(Integer id);  // select  query  get

    // 所有字段都更新  一种 动态更新  使用xml语法
    void update(Emp emp);
    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp getUserByUsernameAndPassword(Emp emp);

    @Delete("delete from emp where dept_id=#{id}")
    void deleteByDeptId(Integer id);
}
